<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>从字符串中获取图像尺寸信息</title>
 </head>
 <body class="docs"><div id="layout">
  <div id="layout-content"><div id="function.getimagesizefromstring" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">getimagesizefromstring</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.4.0, PHP 7)</p><p class="refpurpose"><span class="refname">getimagesizefromstring</span> &mdash; <span class="dc-title">从字符串中获取图像尺寸信息</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.getimagesizefromstring-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>getimagesizefromstring</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$imagedata</code></span>
   [, <span class="methodparam"><span class="type">array</span> <code class="parameter reference">&$imageinfo</code></span>
  ] ) : <span class="type">array</span></div>

  <p class="para rdfs-comment">
   同 <span class="function"><a href="getimagesize.html" class="function">getimagesize()</a></span> 函数。
   区别是 <span class="function"><strong>getimagesizefromstring()</strong></span> 第一个参数是图像数据的字符串表达，而不是文件名。
  </p>
  <p class="para">
   关于本函数如何工作的更多信息请参见
   <span class="function"><a href="getimagesize.html" class="function">getimagesize()</a></span> 函数。
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.getimagesizefromstring-parameters">
  <h3 class="title">参数</h3>
  <dl>

   
    <dt>
<code class="parameter">imagedata</code></dt>

    <dd>

     <p class="para">
      图像数据的字符串表示。
     </p>
    </dd>

   
   
    <dt>
<code class="parameter">imageinfo</code></dt>

    <dd>

     <p class="para">
      参见 <span class="function"><a href="getimagesize.html" class="function">getimagesize()</a></span> 函数。
     </p>
    </dd>

   
  </dl>

 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.getimagesizefromstring-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   参见 <span class="function"><a href="getimagesize.html" class="function">getimagesize()</a></span> 函数。
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.getimagesizefromstring-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-3649">
    <p><strong>Example #1 <span class="function"><strong>getimagesizefromstring()</strong></span> 函数例程</strong></p>
    <div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$img&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'/path/to/test.png'</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">//&nbsp;以文件方式打开<br /></span><span style="color: #0000BB">$size_info1&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">getimagesize</span><span style="color: #007700">(</span><span style="color: #0000BB">$img</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;以字符串格式打开<br /></span><span style="color: #0000BB">$data&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">file_get_contents</span><span style="color: #007700">(</span><span style="color: #0000BB">$img</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$size_info2&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">getimagesizefromstring</span><span style="color: #007700">(</span><span style="color: #0000BB">$data</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.getimagesizefromstring-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="getimagesize.html" class="function" rel="rdfs-seeAlso">getimagesize()</a> - 取得图像大小</span></li>
   </ul>
  </p>
 </div>

 
</div></div></div></body></html>